23 #define foreach(x, v) for (typeof (v).begin() x=(v).begin(); x !=(v).end(); ++x)
24 #define For(i, a, b) for (int i=(a); i<(b); ++i)
25 #define D(x) cout << #x " is " << x << endl
29 set
< vector
<int> > seen
;
33 while (cin
>> n
>> k
) {
34 memset(used
, 0, sizeof used
);
36 For(i
, 0, n
) cin
>> prof
[i
];
38 int ans_min
= 1<<28, ans_max
= -(1<<28);
44 for (int i
= 0; i
< (n
/k
); ++i
) {
50 sort(card
.begin(), card
.end());
52 ans_min
= min(sum
, ans_min
);
53 ans_max
= max(sum
, ans_max
);
57 For(i
, 0, n
) if (!used
[i
]) unused
.push_back(prof
[i
]);
58 sort(unused
.begin(), unused
.end());
59 if (unused
.size() >= (n
/k
) and seen
.size() < k
) {
60 assert(unused
.size() >= (n
/k
));
61 int small
= 0, big
= 0;
62 for (int i
= 0; i
< (n
/k
); ++i
) small
+= unused
[i
];
63 for (int i
= 0; i
< (n
/k
); ++i
) big
+= unused
[unused
.size() - 1 - i
];
64 ans_min
= min(small
, ans_min
);
65 ans_min
= min(big
, ans_min
);
67 ans_max
= max(small
, ans_max
);
68 ans_max
= max(big
, ans_max
);
71 printf("%.12lf %.12lf\n", 1.0 * ans_min
/ f
, 1.0 * ans_max
/ f
);